1. Field of the Invention
This invention relates to the field of object-oriented computer applications, and, more specifically, to object-oriented image processing applications.
2. Background Art
In the field of computer graphics, images are typically represented as a row-column array of pixels stored as image data within an image file. The image data corresponding to each pixel indicates the color value associated with that pixel. Often, these color values are comprised of individual components, such as the red, green and blue components of an RGB image, all of which contribute to the color of the associated pixel. Each component is considered a separate "channel" of an image. For example, all red components of an RGB image are considered elements of the red channel.
Other visual aspects may also be associated with pixels by placing corresponding data in a separate channel of an image. One commonly used image channel is the alpha channel, which contains information about pixel transparency for use in the mixing of images. When the alpha channel is used, each pixel, in addition to other components, includes an alpha component value. This alpha value is used to scale each of the other components of the respective pixel to factor the transparency value into the pixel, such as for use in compositing images. Compositing digital images using the alpha channel is further described in the paper by T. Porter and T. Duff entitled, "Compositing Digital Images," SIGGRAPH 1984, in Computer Graphics, Vol. 18, No. 3, pp. 253-259.
In some processing applications, the pixel components are stored in a premultiplied state, i.e. prescaled by alpha, whereas in other applications, the pixel components are not premultiplied. Unfortunately, it is not always possible to insure that a given image file is of the appropriate state for a given application.
The value for alpha varies in the range of zero to one (typically encoded as zero to (2.sup.n -1), where n is the number of bits representing alpha) with zero being completely transparent and one being completely opaque. Values in between are considered translucent. The alpha value is used to modify the values of the color components in a pixel such that, when processed, the RGB values for each pixel are multiplied by alpha, i.e., the non-premultiplied ARGB data (.alpha., R, G, B) of pixel x,y yields RGB data (.alpha.R, .alpha.G, .alpha.B). Premultiplied data is stored in the form (.alpha., .alpha.R, .alpha.G, .alpha.B). An example of non-premultiplied data and premultiplied data, given eight-bit component precision (.alpha.:0-1.0; R, G, B:0-255), .alpha.=0.25, R=100, G=10 and B=132, is:
______________________________________ Non-Premultiplied (.alpha., R, G, B) Premultiplied (.alpha., .alpha.R, .alpha.G, .alpha.B) (0.25, 100, 10, 130) (0.25, 25, 2.5, 32.5) ______________________________________ L = 01000000 .alpha.= 01000000 R = 01100100 .alpha.R = 00011001 G = 00001010 .alpha.G = 00000011 B = 10000010 .alpha.B = 00100001 ______________________________________
An advantage of premultiplied data is that multiplication by alpha is not necessary in image processing steps that utilize the alpha value. The multiplication has been done beforehand, reducing the processor time needed to process an image. The time savings are proportional to the number of components in each pixel, and the number of pixels in the image. Some images are therefore stored in the premultiplied state to exploit this time saving advantage.
A disadvantage of using premultiplied data is that multiplication by a can cause color information to be lost. Specifically, color resolution may be lost due to the finite bit precision of the component values and the rounding (or truncating) effect of binary multiplication. In the above example, premultiplication of the green and blue component values yields .alpha.G=2.5 and .alpha.B=32.5, which are rounded to .alpha.G=3 and .alpha.B=33, respectively. If the actual unmultiplied green and blue values were needed, for instance in precise color comparison or thresholding operations, the premultiplied values would be divided by alpha to yield G'=12 and B'=132, rather than the actual G=10 and B=130, Thus, resolution errors would occur that could affect processing. The resolution error increases for smaller .alpha., and may effectively drive small component values to zero. Some images are therefore stored in a non-premultiplied state to avoid the resolution problems of premultiplied data.
Most applications or application methods are written to process image data received in one state, the premultiplied state or the non-premultiplied state. However, with the proliferation of countless images and image formats across networks, or distributed via CD-ROM, there is no mechanism for insuring that the premultiplication state of a given image file matches that expected by a processing application, barring special handling by the application.
In the prior art, Kodak's FlashPix.TM. image format (FlashPix Format Specification, Version 1.0, .COPYRGT.1996 Eastman Kodak Company) identifies premultiplied or non-premultiplied image data by providing a bit within the image file that indicates the premultiplication state. This approach requires parsing of the image data file to locate and interpret the corresponding bit. No mechanism exists for associating a premultiplication state with other image data file formats. Further, FlashPix does not itself insure that the state of the image data matches that expected by an application. Beyond file format issues, existing general purpose graphics and imaging APIs do not support handling different alpha premultiplication states for images.